package com.ktjy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ktjy.dto.PostDTO;
import com.ktjy.pojo.SysPost;
import com.ktjy.mapper.SysPostMapper;
import com.ktjy.service.ISysPostService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 岗位信息表 服务实现类
 * </p>
 *
 * @author jjx
 * @since 2025-07-31
 */
@Service
public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> implements ISysPostService {
    @Autowired
    SysPostMapper sysPostMapper;

    @Override
    public IPage<SysPost> findPage(PostDTO postDTO, Integer pageNo, Integer pageSize) {
        //构造分页条件
        Page page=new Page(pageNo,pageSize);
        //构造查询条件
        QueryWrapper qw=new QueryWrapper();
        if(postDTO.getPostCode()!=null && !postDTO.getPostCode().isEmpty()){
            qw.eq("post_code",postDTO.getPostCode());
        }
        if(postDTO.getPostName()!=null && !postDTO.getPostName().isEmpty()){
            qw.like("post_name",postDTO.getPostName());
        }
        if(postDTO.getStatus()!=null && !postDTO.getStatus().isEmpty()){
            qw.eq("status",postDTO.getStatus());
        }
        return sysPostMapper.selectPage(page,qw);
    }
}
